{
    const tinify = require('tinify');
    const fs = require('fs');
    const path = require('path');
    init.call();
    tinifyPng();
    function init() {
        console.log(`初始化tinify参数`);
        // 秘钥
        const dic = {
            'key': 'Gi7dwKoGcu1rgTJnUuTTh3bYDZpFaFp8'
        };
        tinify.key = dic.key;
    }

    function tinifyPng() {
        let web = path.resolve(__dirname, '../Git/Gpl-Own/Chivalrous_man_city_newstruct/build/web-mobile/res/raw-assets');
        const source = tinify.fromFile("mapnew.jpg");
        // source.toFile("mapnow.jpg");
        console.log(web);

        let pa = fs.readdirSync(web);
        pa.forEach(function (ele, index) {
            let info = fs.statSync(web + "/" + ele)
            if (info.isDirectory()) {
                console.log("dir: " + ele)
                //readDirSync(path + "/" + ele);
            } else {
                console.log("file: " + ele)
            }
        })

    }

}